#include "common.h"
#include "file_op.h"

using namespace std;
using namespace zsyuung_fs;





int main(void)
{
    const char* filename = "file_op.txt";
    largefile::FileOperation *fileOp = new largefile::FileOperation(filename, O_CREAT | O_RDWR | O_LARGEFILE);
    
    int fd = fileOp->open_file();
    if(fd < 0)
    {
        fprintf(stderr, "open file %s failed, desc:%s\n", filename, strerror(-fd));
        return -1;
    }
    
    char buffer[64];
    memset(buffer, '9', 64);
    int ret = fileOp->pwrite_file(buffer, 64, 1024); 
    if(ret < 0)
    {
        fprintf(stderr, "pwrite file %s write failed, desc:%s\n", filename, strerror(-ret));
    }

    fileOp->close_file();

    memset(buffer, 0, 64);
    ret = fileOp->pread_file(buffer, 64, 1024);
    if(ret < 0)
    {
        fprintf(stderr, "pread file %s write failed, desc:%s\n", filename, strerror(-ret));
    }

    printf("%s\n", buffer);

    return 0;
}
